﻿using System;
using System.IO;

namespace Program12
{
    class Program
    {
       //Directory文件夹的处理
        static void Main(string[] args)
        {
            ////创建文件夹
            //Directory.CreateDirectory(@"c:\AAA");
            //Console.WriteLine("创建成功！");

            //try
            //{
            //    Directory.Delete(@"c:\AAA");
            //    Console.WriteLine("删除文件成功！");
            //}
            //catch
            //{
            //    Console.WriteLine("文件夹不存在");
            //}


            ////文件夹剪切   目前不能跨磁盘剪切 
            //string soureFolder = @"C:\AAA";
            //string targeFolder =@"C:\BBB";
            //Directory.Move(soureFolder, targeFolder);
            //Console.WriteLine("剪切成功！");

            //查询某个文件夹是否存在 
            if (Directory.Exists(@"c:\AAA"))
            {
                for (var i = 0; i < 100; i++)
                {
                    Directory.CreateDirectory(@"c:\AAA\" + i);  // 在AAA里面创建100个文件夹
                }
            }

            //在控制台列出文件夹
            string keyPath = "99";   //这是定义string 文件夹里面的99文件夹
            string[] path = Directory.GetDirectories(@"c:\AAA");
            foreach (var p in path)
            {
                if (p.Contains(keyPath))   //判断
                {
                    Console.WriteLine(p);   //输出
                    break;
                }
                //Console.WriteLine(p);
            }


            
        }
    }
}
